#include <bits/stdc++.h>
using namespace std;


const int N = 1000005;

int vis[N];
int a[N];


void so()
{

     int n;
     int ans = 0;
    cin >> n;
    memset(vis, 0, sizeof vis);
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        vis[a[i]]++;
        if(vis[a[i]] > 1) ans += a[i];
    }
    cout << ans << endl;

}



int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    int T;
    cin >> T;
    while(T--)
    {
        so();
    }
    return 0;
}
